<template>
  <div class="content">
    <div class="loginBox">
      <div class="title">房屋租赁系统</div>
      <div class="inpVal">
        <span>用户名：</span>
        <input type="text" v-model.trim="userAccount" autofocus/>
      </div>
      <div class="inpVal">
        <span>密&nbsp;&nbsp;&nbsp;码：</span>
        <input type="password" v-model.trim="password" />
      </div>
      <div class="loginBtn"><button @click="loginBtn">登录</button></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userAccount: "",
      password: "",
    };
  },
  // created(){
  //   this.$nextTick(()=>{
  //     this.$refs.userInp.focus()
  //   })
  // },
  methods: {
    loginBtn(){
        if (this.userAccount == "") {
            alert("请输入用户名")
        }else if (this.password == "") {
            alert("请输入密码")
        }else{
            this.$router.push('/home')
        }
    }
  },

  // directives: {
  //   focus: {
  //     // 指令的定义
  //     inserted: function (el) {
  //       el.focus();
  //     },
  //   },
  // },
};
</script>

<style lang="less" scoped>
.content {
  height: 100vh;
  width: 100%;
  background: url("../assets/bg.png") no-repeat bottom right;
  background-size: 150% 140%;
  .loginBox {
    height: 260px;
    width: 350px;
    position: absolute;
    padding: 15px;
    box-sizing: border-box;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 7px;
    border: 2px solid #fff;
    .title {
      height: 60px;
      width: 100%;
      text-align: center;
      line-height: 50px;
      font-size: 20px;
      color: #541969;
      font-weight: 600;
    }
    .inpVal {
      width: 100%;
      height: 60px;
      line-height: 30px;
      span {
        color: #541969;
      }
      input {
        outline: none;
        width: 239px;
        height: 25px;
      }
    }
    .loginBtn {
      button {
        height: 35px;
        width: 100%;
        background: #91419a;
        border: none;
        color: #fff;
        cursor: pointer;
      }
    }
  }
}
</style>